package com.hans.scala

/**
 * 守卫
 * Created by Juntao.Zhang on 2014/4/16.
 */
object Guard {
  def main(args: Array[String]) {
    matchGuard("hans")
    matchGuard("zjt")
    forGuard()
  }

  def forGuard() {
    import scala.collection.JavaConverters.mapAsScalaMapConverter
    for ((k, v) <- System.getProperties.asScala.toMap if k.toString.contains("java")) {
      println(k + "," + v)
    }
  }

  def matchGuard(tmp: Any) {
    tmp match {
      case x: String if x == "hans" => println("hans")
      case _ => println("not find")
    }
  }
}
